package com.example.web.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import com.example.web.entity.User;
import com.example.web.service.UserService;
import com.example.web.tool.R;

import lombok.extern.slf4j.Slf4j;

@Slf4j
@RestController
public class User2Controller {

	@Autowired
	UserService userService;

	@GetMapping("/user{id}")
	public R getUser(@PathVariable("id") Integer id) {
		log.info("id:{}", id);
		return R.ok().put("data", userService.selectById(id));
	}

	@GetMapping("user/{id}")
	public R getUserById(@PathVariable("id") Integer id) {
		log.info("id:{}", id);
		return R.ok().put("data", userService.getUserById(id));
	}
	
	@GetMapping("/userList")
	public List<User> getList(){
		return userService.getList();
	}
	
}
